package wang.j100.uc.module.system.dal.mysql.social;

import wang.j100.uc.framework.mybatis.core.mapper.BaseMapperX;
import wang.j100.uc.framework.mybatis.core.query.LambdaQueryWrapperX;
import wang.j100.uc.module.system.dal.dataobject.social.SubSocialUserBindDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface SocialUserBindMapper extends BaseMapperX<SubSocialUserBindDO> {

    default void deleteByUserTypeAndUserIdAndSocialType(Integer userType, Long userId, Integer socialType) {
        delete(new LambdaQueryWrapperX<SubSocialUserBindDO>()
                .eq(SubSocialUserBindDO::getUserType, userType)
                .eq(SubSocialUserBindDO::getUserId, userId)
                .eq(SubSocialUserBindDO::getSocialType, socialType));
    }

    default void deleteByUserTypeAndSocialUserId(Integer userType, Long socialUserId) {
        delete(new LambdaQueryWrapperX<SubSocialUserBindDO>()
                .eq(SubSocialUserBindDO::getUserType, userType)
                .eq(SubSocialUserBindDO::getSocialUserId, socialUserId));
    }

    default SubSocialUserBindDO selectByUserTypeAndSocialUserId(Integer userType, Long socialUserId) {
        return selectOne(SubSocialUserBindDO::getUserType, userType,
                SubSocialUserBindDO::getSocialUserId, socialUserId);
    }

    default List<SubSocialUserBindDO> selectListByUserIdAndUserType(Long userId, Integer userType) {
        return selectList(new LambdaQueryWrapperX<SubSocialUserBindDO>()
                .eq(SubSocialUserBindDO::getUserId, userId)
                .eq(SubSocialUserBindDO::getUserType, userType));
    }

    default SubSocialUserBindDO selectByUserIdAndUserTypeAndSocialType(Long userId, Integer userType, Integer socialType) {
        return selectOne(new LambdaQueryWrapperX<SubSocialUserBindDO>()
                .eq(SubSocialUserBindDO::getUserId, userId)
                .eq(SubSocialUserBindDO::getUserType, userType)
                .eq(SubSocialUserBindDO::getSocialType, socialType));
    }

}
